<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"

      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <!--Inicia la composicion de la pagina en la plantilla-->
    <ui:composition template="/resources/default/template/plantilla.xhtml">

        <!--Segmento que define el contenido del header-->
        <ui:define name="head">
            <f:loadBundle basename="user.allocation.label_es"  var="label" />
            <f:loadBundle basename="user.allocation.message_es" var="message" />
            <title><h:outputText value="#{label.title1}"/></title>

        </ui:define>

        <ui:define name="autocomplete"><ui:include src="../autocomplete/main.xhtml"/></ui:define>

        <ui:define name="moduleTitle">#{label.title1}</ui:define>
        <!--Segmento que define el contenido de la pagina-->
        <ui:define name="content">
            <p:growl id="messages" showDetail="true"/>
            <c:set var="list" value="#{user_allocation.listTable()}" />
            <h:outputText value="#{label.title2}" class="label" rendered="#{logged.masterId == 0}" />
            <h:outputText value="#{label.title3}" class="label" rendered="#{logged.masterId != 0 and empty list}" />
            
            <h:form rendered="#{not empty list and logged.masterId != 0}">  
                <div class="field" >
                    <h:outputText value="#{label.field1}" class="label" />
                    <h:inputText   value="#{logged.getMasterName()}"  disabled="true"  class="textfield" />  
                </div>

                <h:panelGroup layout="block" class="tableWrapper" rendered="#{not empty list and logged.masterId != 0}">
                    <h:dataTable  id ="table" var="p" value="#{list}" class="dataTable">
                        <h:column>
                            <f:facet name="header">#{label.field7}</f:facet>
                            <h:outputText   value="#{user_allocation.cant}" />
                        </h:column>
                        <h:column>
                            <h:selectBooleanCheckbox   value="#{user_allocation.checked[p.id]}" disabled="#{user_allocation.acceso((user_allocation.caduca[p.id]))}"  />
                        </h:column>
                        <h:column >
                            <f:facet name="header">#{label.field3}</f:facet>
                            <h:outputText value="#{p.gps_user.imei}"/>
                        </h:column>
                        <h:column >
                            <f:facet name="header">#{label.field5}</f:facet>
                            <h:outputText value="#{p.gps_user.nombre}"/>
                        </h:column>

                        <h:column >
                            <f:facet name="header">#{label.field6}</f:facet>
                            <h:outputText value="#{p.company_user.nombre}" />
                        </h:column>
                        <h:column >
                            <f:facet name="header">#{label.field8}</f:facet>
                            <h:outputText value="#{p.gps_user.caducidad}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">#{label.field9}</f:facet>
                            <h:outputLabel   value="#{user_allocation.state[p.id]}" class="label"   />
                        </h:column>
                    </h:dataTable>
                    <h:commandButton value="#{label.button2}" class="button" actionListener="#{user_allocation.insertTable()}" onclick="return verificar('#{message.m7}');">
                        <f:param name="required" value="true"/>
                    </h:commandButton>
                </h:panelGroup>        
            </h:form>  
        </ui:define>
    </ui:composition>
</html>
